#ifndef DBPAGE_H
#define DBPAGE_H

#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <mysql.h>
using namespace std;


class DbPage
{
public:
    DbPage();
    vector< vector<string> >* search(string ,int,string);
    int page, records, first, previous, next, last, total;
    string searchText, sql, whereSql, orderbySql;
    vector<string> columnList,headerList;
    bool firstOk();
    bool previousOk();
    bool nextOk();
    bool lastOk();
    int previousPage();
    int nextPage();
    int lastPage();
    vector< vector<string> >* model;

private:

    vector< vector<string> >* executeSql(string sql);
    void clean();
    string table, columns, headers, orderby;
    string createSql();
    vector< vector<string> >* search();
    int searchCount();
    bool connect();
    bool isValid();
    string numberToString(int number);

    MYSQL *conn;
    MYSQL_RES *res;
    MYSQL_ROW row;
};

#endif // DBPAGE_H
